//
//  HomeViewModel.swift
//  SwiftUI_App
//
//  Created by qingzhou on 2021/6/25.
//

import Foundation
import SwiftUI

final class HomeViewModel: ObservableObject {
    public let homeBannerWidth = SCREEN_WIDTH - 30
    public let homeBannerHeight:CGFloat = 150
    
    /// 首页Model
    private let homeModel:HomeModel = load("HomeData.json")
    
    private var homeBannerArray:[String] {
        return [homeModel.bannerImages.last!] + homeModel.bannerImages + [homeModel.bannerImages.first!]
    }
}

extension HomeViewModel {
    /// banner 个数
    /// - Returns: description
    func homeBannerCount() -> NSInteger {
        return homeBannerArray.count
    }
    
    /// banner 图片
    /// - Parameter indexPath: indexPath description
    /// - Returns: description
    func bannerImage(_ indexPath:NSInteger) -> String {
        
        return homeBannerArray[indexPath]
    }
}
